#include "com/cns/android/weather/WidgetInfo.h"
#include <binder/Parcel.h>

namespace com {
namespace cns {
namespace android {
namespace weather {


WidgetInfo::WidgetInfo() {
}

WidgetInfo::WidgetInfo(const ::android::Parcel& parcel) {
    readFromParcel(&parcel);
}

WidgetInfo::~WidgetInfo() {
}

WidgetInfo::WidgetInfo(const WidgetInfo& o) :
    province(o.province),
    city(o.city),
	district(o.district),
    weather(o.weather),
	currentTemp(o.currentTemp),
    minTemp(o.minTemp),
	maxTemp(o.maxTemp),
    AQI(o.AQI),
	PM25(o.PM25),
    updateTime(o.updateTime) 
{
}

WidgetInfo& WidgetInfo::operator=(const WidgetInfo& o) {
    province = o.province;
    city = o.city;
    district = o.district;
	weather = o.weather;
    currentTemp = o.currentTemp;
    minTemp = o.minTemp;
	maxTemp = o.maxTemp;
    AQI = o.AQI;
    PM25 = o.PM25;
	updateTime = o.updateTime;
	
    return *this;
}

::android::status_t WidgetInfo::writeToParcel(::android::Parcel *parcel) const {
    ::android::status_t res;

    if (parcel == nullptr) return ::android::BAD_VALUE;

	res = parcel->writeString16(province);
	if (res != ::android::OK) return res;

	res = parcel->writeString16(city);
	if (res != ::android::OK) return res;
	
	res = parcel->writeString16(district);
    	if (res != ::android::OK) return res;

    	res = parcel->writeString16(weather);
    	if (res != ::android::OK) return res;

	res = parcel->writeString16(currentTemp);
    	if (res != ::android::OK) return res;

    	res = parcel->writeString16(minTemp);
	if (res != ::android::OK) return res;

	res = parcel->writeString16(maxTemp);
	if (res != ::android::OK) return res;

	res = parcel->writeString16(AQI);
	if (res != ::android::OK) return res;

	res = parcel->writeString16(PM25);
    	if (res != ::android::OK) return res;

    	res = parcel->writeString16(updateTime);
    	return res;
}

::android::status_t WidgetInfo::readFromParcel(const ::android::Parcel *parcel) {
    if (parcel == nullptr) return ::android::BAD_VALUE;

	province = readMaybeEmptyString16(parcel);
	city = readMaybeEmptyString16(parcel);
	district = readMaybeEmptyString16(parcel);
	weather = readMaybeEmptyString16(parcel);
	currentTemp = readMaybeEmptyString16(parcel);
	minTemp = readMaybeEmptyString16(parcel);
	maxTemp = readMaybeEmptyString16(parcel);
	AQI = readMaybeEmptyString16(parcel);
 	PM25 = readMaybeEmptyString16(parcel);
	updateTime = readMaybeEmptyString16(parcel);

    return ::android::OK;
}

void WidgetInfo::setProvince(const ::android::String16& province)
{
	this->province = province;
}
void WidgetInfo::setCity(const ::android::String16& city)
{
	this->city = city;
}
void WidgetInfo::setDistrict(const ::android::String16& district)
{
	this->district = district;
}
void WidgetInfo::setWeather(const ::android::String16& weather)
{
	this->weather = weather;
}
void WidgetInfo::setCurrentTemp(const ::android::String16& currentTemp)
{
	this->currentTemp = currentTemp;
}
void WidgetInfo::setMinTemp(const ::android::String16& minTemp)
{
	this->minTemp = minTemp;
}
void WidgetInfo::setMaxTemp(const ::android::String16& maxTemp)
{
	this->maxTemp = maxTemp;
}
void WidgetInfo::setAQI(const ::android::String16& AQI)
{
	this->AQI = AQI;
}
void WidgetInfo::setPM25(const ::android::String16& PM25)
{
	this->PM25 = PM25;
}
void WidgetInfo::setUpdateTime(const ::android::String16& updateTime)
{
	this->updateTime = updateTime;
}

const ::android::String16& WidgetInfo::getProvince() const
{
	return province;
}
const ::android::String16& WidgetInfo::getCity() const
{
	return city;
}
const ::android::String16& WidgetInfo::getDistrict() const
{
	return district;
}
const ::android::String16& WidgetInfo::getWeather() const
{
	return weather;
}
const ::android::String16& WidgetInfo::getMinTemp() const
{
	return minTemp;
}
const ::android::String16& WidgetInfo::getMaxTemp() const
{
	return maxTemp;
}
const ::android::String16& WidgetInfo::getAQI() const
{
	return AQI;
}
const ::android::String16& WidgetInfo::getPM25() const
{
	return PM25;
}
const ::android::String16& WidgetInfo::getUpdateTime() const
{
	return updateTime;
}

::android::String16 WidgetInfo::readMaybeEmptyString16(const ::android::Parcel *parcel) {
    size_t len;
    const char16_t* str = parcel->readString16Inplace(&len);

    if (str != nullptr) {
        return ::android::String16(str, len);
    } else {
        return ::android::String16();
    }
}

}
}  // namespace android
}  // namespace cns
}  // namespace com
